home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / polyLaunchPaintReduceTool.me < prev    next >
Encoding:
Text File  |  2003-07-17  |  2.5 KB  |  81 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. global proc polyLaunchPaintReduceTool() 
  18. //
  19. // Description:
  20. // A convenience procedure for launching the paint reduce weights tool.
  21. //
  22. {
  23.  
  24.     // Sometimes when the paint tool is launched from the Edit Polygons menu
  25.     // the artAttrCreateMenuItems.mel file has not been sourced. Do it now
  26.     // to make sure we execut artSetToolAndSelectAttr.
  27.     //
  28.     if (`whatIs artSetToolAndSelectAttr` == "Unknown" ) 
  29.     { 
  30.         source artAttrCreateMenuItems.mel; 
  31.     } 
  32.  
  33.     // Check selection list validity
  34.     //
  35.     string $sel[] = `ls -sl`;
  36.     if ( size( $sel ) == 0 ) {
  37.         warning("Please select a polyReduce node (or a mesh upstream or downstream of one).");
  38.         return;
  39.     }
  40.  
  41.     if ( size( $sel ) > 1 ) {
  42.         warning("Multiple objects selected: Attempting to paint only the first item in selection list.");
  43.     }
  44.  
  45.     // Try to find a reduce node. Look downstream first. 
  46.     //
  47.     string $nodes[] = `listHistory -future true $sel[0]`;
  48.     string $node = "";
  49.     string $target = "";
  50.     for ($node in $nodes) {
  51.         if ( "polyReduce" == `nodeType $node` ) {
  52.             $target = $node;
  53.             break;
  54.         }
  55.     }
  56.  
  57.     // If no reduce node is found downstream, try upstream.
  58.     //
  59.     if ( "" == $target ) {
  60.         $nodes = `listHistory -future false $sel[0]`;
  61.         for ($node in $nodes) {
  62.             if ( "polyReduce" == `nodeType $node` ) {
  63.                 $target = $node;
  64.                 break;
  65.             }
  66.         }
  67.     }
  68.     
  69.  
  70.     // If we still haven't found a reduce node, then the selection isn't
  71.     // paintable.
  72.     //
  73.     if ( "" == $target ) {
  74.         warning("Please select a polyReduce node (or a mesh upstream or downstream of one).");
  75.         return;
  76.     }    
  77.  
  78.     artSetToolAndSelectAttr( "artAttrCtx", "polyReduce." + $target + ".weights" );
  79.  
  80. }
  81.